﻿Imports ccapps.persistent.CustomerDetailsEditPersistent
Public Class Customer_Details_Edit
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


        If Session("user") = "" Or Session("user") Is Nothing Then
            ' Response.Redirect("../../login.aspx")
            Session("message") = "!!Session Timeout!!,Tekrar Giriş Yapmalısınız"
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()
        End If

    End Sub



    Protected Sub btnCustcodeSearch_Click(sender As Object, e As EventArgs) Handles btnCustcodeSearch.Click
        Try
            lblCustomerID.Text = ""
            TB_SearchMSISDN.Text = ""
            Clear()
            FillIDTypeList()
            FillLanguage()
            FillNationality()
            FillSector()


            Dim pin_SearchCustcode As String = TB_SearchCustcode.Text
            Dim dt As DataTable = GetCustInfoFromCustcode(pin_SearchCustcode)


            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows


                    lblCustomerID.Text = dr2("CUSTOMER_ID").ToString()


                    ErrorMessage.Text = ""
                Next

            Else
                ErrorMessage.Text = "Girmiş olduğunuz Custcode'a ait veri bulunamamıştır."


            End If

            Dim customer_id As Integer = Convert.ToInt32(lblCustomerID.Text)
            Dim dtcustcontrol As DataTable = ccapps.persistent.CustomerDetailsEditPersistent.CustomerTariffType(customer_id)
            Dim tarifftype As String = dtcustcontrol.Rows(0)(0).ToString

            If tarifftype = "C" Then
                btnTCNo0.Visible = False
                CheckBoxMernis.Visible = False

            Else
                btnTCNo0.Visible = True
                CheckBoxMernis.Visible = True

            End If



        Catch ex As Exception
            ErrorMessage.Text = "İşleminiz gerçekleşmemiştir.Lütfen tekrar deneyiniz."
        End Try
    End Sub

    Private Sub FillIDTypeList()

        DDL_IDTYPE.Items.Clear()
        Dim dt As DataTable = GetIDTypeList()

        If dt.Rows.Count > 0 Then
            For Each dr As DataRow In dt.Rows
                DDL_IDTYPE.Items.Add(New ListItem(dr("IDTYPE_NAME").ToString(), dr("IDTYPE_CODE").ToString()))
            Next
        End If
    End Sub

    Private Sub FillNationality()

        DDL_Nationality.Items.Clear()
        Dim dt As DataTable = GetNationality()

        If dt.Rows.Count > 0 Then
            For Each dr As DataRow In dt.Rows
                DDL_Nationality.Items.Add(New ListItem(dr("Country_Name").ToString(), dr("COUNTRY_ID").ToString()))
            Next
        End If
    End Sub


    Private Sub FillLanguage()

        DDL_Language.Items.Clear()

        Dim dt As DataTable = GetLanguage()

        If dt.Rows.Count > 0 Then
            For Each dr As DataRow In dt.Rows
                DDL_Language.Items.Add(New ListItem(dr("LNG_DES").ToString(), dr("LNG_ID").ToString()))
            Next
        End If
    End Sub

    Private Sub FillSector()

        DDL_Sector.Items.Clear()
        Dim dt As DataTable = GetSectorList()

        If dt.Rows.Count > 0 Then
            For Each dr As DataRow In dt.Rows
                DDL_Sector.Items.Add(New ListItem(dr("tradename").ToString(), dr("tradecode").ToString()))
            Next
        End If
    End Sub

    Protected Sub btnMSISDNSearch_Click(sender As Object, e As EventArgs) Handles btnMSISDNSearch.Click

        Try

            lblCustomerID.Text = ""
        TB_SearchCustcode.Text = ""
        Clear()
        FillIDTypeList()
        FillLanguage()
        FillNationality()
        FillSector()
        Dim pin_SearchMSISDN As String = TB_SearchMSISDN.Text.Trim()
        Dim dt As DataTable = GetCustInfoFromMSISDN(pin_SearchMSISDN)
           

        If dt.Rows.Count > 0 Then
            For Each dr2 As DataRow In dt.Rows


                lblCustomerID.Text = dr2("CUSTOMER_ID").ToString()

                ErrorMessage.Text = ""
            Next

        Else
            ErrorMessage.Text = "Girmiş olduğunuz MSISDN'e ait veri bulunamamıştır."

            End If


            Dim customer_id As Integer = Convert.ToInt32(lblCustomerID.Text)
            Dim dtcustcontrol As DataTable = ccapps.persistent.CustomerDetailsEditPersistent.CustomerTariffType(customer_id)
            Dim tarifftype As String = dtcustcontrol.Rows(0)(0).ToString

            If tarifftype = "C" Then
                btnTCNo0.Visible = False
                CheckBoxMernis.Visible = False

            Else
                btnTCNo0.Visible = True
                CheckBoxMernis.Visible = True

            End If


            If tarifftype = "M" Then
                PrintInvoice.Visible = False
            Else
                PrintInvoice.Visible = True
            End If

        Catch ex As Exception
            ErrorMessage.Text = "MSISDN e ait veri bulunamamış veya bir hata ile karşılaşılmıştır.Lütfen tekrar deneyiniz."
        End Try
    End Sub

    
    Protected Sub btnGetInfo_Click(sender As Object, e As EventArgs) Handles btnGetInfo.Click

        Try

            lblMernisStatus.Text = "0"
            Label1.Text = ""




            Dim pin_customer_id As Integer
            pin_customer_id = Convert.ToInt32(lblCustomerID.Text)

            NewInfoTable.Visible = True
            tblContactInfo.Visible = True

            Dim dt As DataTable = GetCustomerContactDetails(pin_customer_id)
            Dim data_level As Integer


            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows

                    TB_CustCode.Text = dr2("CUSTCODE").ToString().ToUpper()
                    TB_CompanyName.Text = dr2("CCNAME").ToString().ToUpper()
                    TB_Status.Text = dr2("Status").ToString().ToUpper()
                    TB_TaxOffice.Text = dr2("CSCOMPREGNO").ToString().ToUpper()
                    TB_TaxNumber.Text = dr2("CSCOMPTAXNO").ToString().ToUpper()
                    TB_Tariff.Text = dr2("rateplan").ToString().ToUpper()
                    TB_PriceGroup.Text = dr2("pricegroup").ToString().ToUpper()
                    TB_DealerID.Text = dr2("DEALER_ID").ToString().ToUpper()
                    TB_AuthorizedPersonMSISDN.Text = dr2("CCSMSNO").ToString().ToUpper()
                    TB_AuthorizedPersonName.Text = dr2("CCFNAME").ToString() + " " + dr2("CCLNAME").ToString().ToUpper()
                    TB_AuthorizedPersonEmail.Text = dr2("CCEMAIL").ToString().ToUpper()
                    If dr2("CS_DATA_LEVEL").ToString() <> "" And dr2("CS_DATA_LEVEL").ToString() <> Nothing And IsDBNull(dr2("CS_DATA_LEVEL").ToString()) Then
                        data_level = Convert.ToInt32(dr2("CS_DATA_LEVEL").ToString())
                        If data_level = 1 Then
                            TB_TCNo.Enabled = False
                            btnTCNo.Enabled = False
                        End If
                    End If

                    TB_TCNo.Text = dr2("CSTCIDNUMBER").ToString()

                    If dr2("IDType_CODE").ToString() <> "" And dr2("IDType_CODE").ToString() <> Nothing Then
                        DDL_IDTYPE.SelectedValue = dr2("IDType_CODE").ToString()
                    Else
                        DDL_IDTYPE.Items.Add(New ListItem("", "bos"))
                        DDL_IDTYPE.SelectedValue = "bos"
                    End If

                    TB_IdentificationNo.Text = dr2("PASSPORTNO").ToString().ToUpper()
                    TB_AuthorizedPersonBirthdate.Text = dr2("BIRTHDATE").ToString().Substring(0, 10)
                    TB_AuthorizedPersonFatherName.Text = dr2("csremark_1").ToString().ToUpper()
                    'If dr2("TradeCode").ToString() <> "" And dr2("TradeCode").ToString() <> Nothing And IsDBNull(dr2("TradeCode").ToString()) Then
                    '    DDL_Sector.SelectedValue = dr2("TradeCode").ToString()
                    '    Label1.Text = dr2("TradeCode").ToString()
                    'Else
                    '    DDL_Sector.Items.Add(New ListItem("", "bos"))
                    '    DDL_Sector.SelectedValue = "bos"

                    'End If


                    If (dr2("INDIVIDUAL_OVERDISC_FLAG").ToString() = "X") Then
                        chckDeactiveOverdiscounting.Checked = True
                    Else
                        chckDeactiveOverdiscounting.Checked = False
                    End If

                    If (dr2("SUPPRESS_INV_EXEMPTION_FLAG").ToString() = "X") Then
                        chckLimitAltiFatura.Checked = True
                    Else
                        chckLimitAltiFatura.Checked = False
                    End If


                    TB_NAME.Text = dr2("CCNAME").ToString().ToUpper()
                    TB_FNAME.Text = dr2("CCFNAME").ToString().ToUpper()
                    TB_LNAME.Text = dr2("CCLNAME").ToString().ToUpper()
                    TB_STREET.Text = dr2("ccstreet").ToString().ToUpper()
                    TB_STREETNO.Text = dr2("ccstreetno").ToString().ToUpper()
                    TB_ADR1.Text = dr2("ccaddr1").ToString().ToUpper()
                    TB_ADR2.Text = dr2("ccaddr2").ToString().ToUpper()
                    TB_ADR3.Text = dr2("ccaddr3").ToString().ToUpper()
                    TB_ZIP.Text = dr2("CCZIP").ToString().ToUpper()
                    IlSecimSME()
                    Dim il As String = dr2("CCCITY").ToString().ToUpper()
                    Dim city, kontrol As String
                    If il.IndexOf("-") = -1 Then
                        Dim dt2 As DataTable = Autocitycode(il)
                        If dt2.Rows.Count > 0 Then
                            For Each dr3 As DataRow In dt2.Rows
                                city = dr3("CITY_COD").ToString()
                                DDL_City.SelectedValue = city
                                Dim datatable_for_ccline As DataTable = Autodistinctcode(dr2("CCLINE2").ToString().ToUpper())
                                ' Label2.Text = dr2("CCLINE2").ToString()
                                If datatable_for_ccline.Rows.Count > 0 Then
                                    For Each dr4 As DataRow In datatable_for_ccline.Rows
                                        IlceSecimArama(city)
                                        Dim ilce As String = dr4("DIST_COD").ToString()
                                        DDL_Note1.SelectedValue = Convert.ToInt32(ilce)
                                    Next
                                Else
                                    IlceSecimArama(city)
                                    DDL_Note1.Items.Add(New ListItem("", "bos"))
                                    DDL_Note1.SelectedValue = "bos"

                                End If
                            Next

                        Else
                            DDL_City.Items.Add(New ListItem("", "bos"))
                            DDL_City.SelectedValue = "bos"
                            DDL_Note1.Items.Add(New ListItem("--Seçiniz--", "bos"))
                            DDL_Note1.SelectedValue = "bos"
                        End If



                    Else
                        Dim il1() As String = il.Split("-")
                        Dim ilce_code As String
                        Dim dt2 As DataTable = Autocitycode(il1(0))


                        If dt.Rows.Count > 0 Then
                            For Each dr3 As DataRow In dt2.Rows
                                city = dr3("CITY_COD").ToString()
                            Next
                        End If

                        DDL_City.SelectedValue = city
                        IlceSecimArama(city)

                        Dim dt3 As DataTable = Autodistinctcode(il1(1))

                        If dt3.Rows.Count > 0 Then
                            For Each dr3 As DataRow In dt3.Rows
                                ilce_code = dr3("DIST_COD").ToString()
                            Next
                        End If





                        DDL_Note1.SelectedValue = Convert.ToInt32(ilce_code)
                    End If

                    TB_ContactPhoneArea1.Text = dr2("cctn_area").ToString().ToUpper()
                    TB_ContactPhone1.Text = dr2("cctn").ToString().ToUpper()
                    TB_ContactPhoneArea2.Text = dr2("cctn2_area").ToString().ToUpper()
                    TB_ContactPhone2.Text = dr2("cctn2").ToString().ToUpper()
                    TB_FaxNoArea.Text = dr2("CCFAX_AREA").ToString().ToUpper()
                    TB_FaxNo.Text = dr2("CCFAX").ToString().ToUpper()
                    TB_Email.Text = dr2("CCEMAIL").ToString().ToUpper()
                    TB_SMSNo.Text = dr2("CCSMSNO").ToString().ToUpper()
                    'TB_DriverLicenceNo.Text = dr2("CSDRIVELICENCE").ToString().ToUpper()
                    If dr2("LanguageCode").ToString() <> "" And dr2("LanguageCode").ToString() <> Nothing Then
                        DDL_Language.SelectedValue = Convert.ToInt32(dr2("LanguageCode").ToString())
                    Else
                        DDL_Language.Items.Add(New ListItem("", "bos"))
                        DDL_Language.SelectedValue = "bos"
                    End If

                    If dr2("CountryCode").ToString() <> "" And dr2("CountryCode").ToString() <> Nothing Then
                        DDL_Nationality.SelectedValue = Convert.ToInt32(dr2("CountryCode").ToString())

                    Else
                        DDL_Nationality.Items.Add(New ListItem("", "bos"))
                        DDL_Nationality.SelectedValue = "bos"
                    End If
                    DDL_CustomerType.SelectedValue = dr2("CSPERSONTYPE").ToString().ToUpper()
                    'TB_DataLevel.Text = dr2("CS_DATA_LEVEL").ToString()
                    TB_FatherName.Text = dr2("csremark_1").ToString().ToUpper()
                    TB_MotherName.Text = dr2("mothers_name").ToString().ToUpper()
                    TB_MotherMaidenName.Text = dr2("csremark_2").ToString().ToUpper()
                    TB_RegistiredProvince.Text = dr2("REGISTERED_PROVINCE").ToString().ToUpper()
                    TB_RegistiredDistrict.Text = dr2("REGISTERED_DISTRICT").ToString().ToUpper()
                    TB_BirthPlaceProvince.Text = dr2("BIRTH_PLACE_PROVINCE").ToString().ToUpper()
                    TB_BirthPlaceDistrict.Text = dr2("BIRTH_PLACE_DISTRICT").ToString().ToUpper()

                    If (dr2("CS_DATA_SHARE").ToString() = "X") Then
                        chckDataShare.Checked = True
                    Else
                        chckDataShare.Checked = False
                    End If
                    TB_Employer.Text = dr2("CSEMPLOYER").ToString()
                    If (dr2("EMPLOYEE").ToString() = "X") Then
                        chckEmployeeOfYourCompany.Checked = True
                    Else
                        chckEmployeeOfYourCompany.Checked = False
                    End If




                Next
                If dt.Rows(0)("TradeCode").ToString() = "" Then
                    DDL_Sector.Items.Add(New ListItem("", "bos"))
                    DDL_Sector.SelectedValue = "bos"
                Else
                    DDL_Sector.SelectedValue = dt.Rows(0)("TradeCode").ToString().ToUpper()

                End If


                'DDL_Sector.SelectedValue = dt.Rows(0)("TradeCode").ToString()
            Else
                ErrorMessage.Text = "Girmiş oldugunuz değere ait veri bulunamamıştır"

            End If

        Catch ex As Exception

            ErrorMessage.Text = "Herhangi bir veri girişi yapılmamıştır. Lütfen custcode veya msisdn girip tekrar deneyiniz."
        End Try

    End Sub

    Protected Sub btnTaxOffice_Click(sender As Object, e As EventArgs) Handles btnTaxOffice.Click

        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim taxOffice As String = TB_TaxOffice.Text.Trim().ToUpper()

            Dim dt As DataTable = UpdateTaxOffice(pin_customer_id, taxOffice)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If

        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

   
    Protected Sub btnTaxNumber_Click(sender As Object, e As EventArgs) Handles btnTaxNumber.Click
        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim taxNumber As String = TB_TaxNumber.Text.Trim().ToUpper()

            Dim dt As DataTable = UpdateTaxNumber(pin_customer_id, taxNumber)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If
        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try


    End Sub

    Protected Sub btnAuthorizedPersonMSISDN_Click(sender As Object, e As EventArgs) Handles btnAuthorizedPersonMSISDN.Click
        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim AuthorizedPersonMSISDN As String = TB_AuthorizedPersonMSISDN.Text.Trim()

            Dim dt As DataTable = UpdateAuthorizedMSISDN(pin_customer_id, AuthorizedPersonMSISDN)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If
        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try

    End Sub

    Protected Sub btnAuthorizedPersonEmail_Click(sender As Object, e As EventArgs) Handles btnAuthorizedPersonEmail.Click
        Try

            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim AuthorizedPersonEmail As String = TB_AuthorizedPersonEmail.Text.ToUpper()

            Dim dt As DataTable = UpdateAuthorizedEmail(pin_customer_id, AuthorizedPersonEmail)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If

        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    Protected Sub btnTCNo_Click(sender As Object, e As EventArgs) Handles btnTCNo.Click
        If lblMernisStatus.Text = "1" Then
            Try
                Label1.Text = ""
                Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text)
                Dim TCNo As String = TB_TCNo.Text

                Dim dt As DataTable = UpdateTCNo2(pin_customer_id, TCNo, TB_FNAME.Text, TB_LNAME.Text, TB_FatherName.Text, TB_MotherMaidenName.Text, TB_AuthorizedPersonBirthdate.Text, TB_RegistiredProvince.Text, TB_RegistiredDistrict.Text)
                If dt.Rows.Count > 0 Then
                    For Each dr2 As DataRow In dt.Rows
                        If (dr2("result").ToString() = "0") Then

                            Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                        Else
                            Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                        End If
                    Next
                End If
            Catch ex As Exception


                Session("message") = ex.Message
                Response.Clear()
                Response.Status = "302 Object Moved"
                Response.RedirectLocation = "CX_Exception.aspx"
                Response.End()




            End Try
        Else
            Try
                Label1.Text = ""
                Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
                Dim TCNo As String = TB_TCNo.Text.Trim()

                Dim dt As DataTable = UpdateTCNo(pin_customer_id, TCNo)
                If dt.Rows.Count > 0 Then
                    For Each dr2 As DataRow In dt.Rows
                        If (dr2("result").ToString() = "0") Then

                            Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                        Else
                            Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                        End If
                    Next
                End If
            Catch ex As Exception


                Session("message") = ex.Message
                Response.Clear()
                Response.Status = "302 Object Moved"
                Response.RedirectLocation = "CX_Exception.aspx"
                Response.End()




            End Try
        End If

      

    End Sub

  


    Protected Sub btnDeactiveOverdiscounting_Click(sender As Object, e As EventArgs) Handles btnDeactiveOverdiscounting.Click
        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())

            Dim Deactive As String
            If chckDeactiveOverdiscounting.Checked = True Then
                Deactive = "Y"
            Else
                Deactive = "N"
            End If


            Dim dt As DataTable = UpdateDeactivateOverdisc(pin_customer_id, Deactive)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "OK") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If
        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    Protected Sub btnLimitAltiFatura_Click(sender As Object, e As EventArgs) Handles btnLimitAltiFatura.Click

        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())

            Dim limitAlti As String
            If chckLimitAltiFatura.Checked = True Then
                limitAlti = "Y"
            Else
                limitAlti = "N"
            End If


            Dim dt As DataTable = UpdateLimitAltiFatura(pin_customer_id, limitAlti)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If

        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    'Protected Sub btnCustomerStreet_Click(sender As Object, e As EventArgs) Handles btnCustomerStreet.Click

    '    Try
    '        Label1.Text = ""
    '        Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
    '        Dim street As String = TB_STREET.Text.Trim().ToUpper()

    '        Dim dt As DataTable = UpdateCustomerStreet(pin_customer_id, street)
    '        If dt.Rows.Count > 0 Then
    '            For Each dr2 As DataRow In dt.Rows
    '                If (dr2("result").ToString() = "0") Then

    '                    Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

    '                Else
    '                    Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
    '                End If
    '            Next
    '        End If

    '    Catch ex As Exception


    '        Session("message") = ex.Message
    '        Response.Clear()
    '        Response.Status = "302 Object Moved"
    '        Response.RedirectLocation = "CX_Exception.aspx"
    '        Response.End()

    '    End Try
    'End Sub


    'Protected Sub btnCustomerStreetNo_Click(sender As Object, e As EventArgs) Handles btnCustomerStreetNo.Click
    '    Try
    '        Label1.Text = ""
    '        Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
    '        Dim street As String = TB_STREETNO.Text.Trim().ToUpper()

    '        Dim dt As DataTable = UpdateCustomerStreetNo(pin_customer_id, street)
    '        If dt.Rows.Count > 0 Then
    '            For Each dr2 As DataRow In dt.Rows
    '                If (dr2("result").ToString() = "0") Then

    '                    Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

    '                Else
    '                    Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
    '                End If
    '            Next
    '        End If

    '    Catch ex As Exception


    '        Session("message") = ex.Message
    '        Response.Clear()
    '        Response.Status = "302 Object Moved"
    '        Response.RedirectLocation = "CX_Exception.aspx"
    '        Response.End()




    '    End Try
    'End Sub

    'Protected Sub btnADR1_Click(sender As Object, e As EventArgs) Handles btnADR1.Click

    '    Try
    '        Label1.Text = ""
    '        Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text)
    '        Dim adr1 As String = TB_ADR1.Text.Trim().ToUpper()

    '        Dim dt As DataTable = UpdateCustomerADR1(pin_customer_id, adr1)
    '        If dt.Rows.Count > 0 Then
    '            For Each dr2 As DataRow In dt.Rows
    '                If (dr2("result").ToString() = "0") Then

    '                    Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

    '                Else
    '                    Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
    '                End If
    '            Next
    '        End If
    '    Catch ex As Exception


    '        Session("message") = ex.Message
    '        Response.Clear()
    '        Response.Status = "302 Object Moved"
    '        Response.RedirectLocation = "CX_Exception.aspx"
    '        Response.End()




    '    End Try
    'End Sub

    'Protected Sub btnADR2_Click(sender As Object, e As EventArgs) Handles btnADR2.Click

    '    Try
    '        Label1.Text = ""
    '        Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text)
    '        Dim adr2 As String = TB_ADR2.Text.Trim().ToUpper()

    '        Dim dt As DataTable = UpdateCustomerADR2(pin_customer_id, adr2)
    '        If dt.Rows.Count > 0 Then
    '            For Each dr2 As DataRow In dt.Rows
    '                If (dr2("result").ToString() = "0") Then

    '                    Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

    '                Else
    '                    Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
    '                End If
    '            Next
    '        End If

    '    Catch ex As Exception


    '        Session("message") = ex.Message
    '        Response.Clear()
    '        Response.Status = "302 Object Moved"
    '        Response.RedirectLocation = "CX_Exception.aspx"
    '        Response.End()




    '    End Try
    'End Sub

    Protected Sub btnADR3_Click(sender As Object, e As EventArgs) Handles btnADR3.Click

        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim adr1 As String = TB_ADR1.Text.Trim().ToUpper()
            Dim adr2 As String = TB_ADR2.Text.Trim().ToUpper()
            Dim adr3 As String = TB_ADR3.Text.Trim().ToUpper()
            Dim street As String = TB_STREET.Text.Trim().ToUpper()
            Dim streetno As String = TB_STREETNO.Text.Trim().ToUpper()

            Dim dt As DataTable = UpdateCustomerADR3(pin_customer_id, adr1, adr2, adr3, street, streetno)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If

        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    Protected Sub btnZIP_Click(sender As Object, e As EventArgs) Handles btnZIP.Click
        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim zip As String = TB_ZIP.Text.Trim().ToUpper()

            Dim dt As DataTable = UpdateCustomerZIP(pin_customer_id, zip)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If

        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    'Protected Sub bntCity_Click(sender As Object, e As EventArgs) Handles bntCity.Click
    '    Try
    '        Label1.Text = ""
    '        Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text)
    '        Dim city As String = TB_CITY.Text.Trim().ToUpper()

    '        Dim dt As DataTable = UpdateCustomerCity(pin_customer_id, city)
    '        If dt.Rows.Count > 0 Then
    '            For Each dr2 As DataRow In dt.Rows
    '                If (dr2("result").ToString() = "0") Then

    '                    Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

    '                Else
    '                    Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
    '                End If
    '            Next
    '        End If

    '    Catch ex As Exception


    '        Session("message") = ex.Message
    '        Response.Clear()
    '        Response.Status = "302 Object Moved"
    '        Response.RedirectLocation = "CX_Exception.aspx"
    '        Response.End()



    '    End Try
    'End Sub

    Protected Sub btnContactPhone1_Click(sender As Object, e As EventArgs) Handles btnContactPhone1.Click
        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim phonearea As String = TB_ContactPhoneArea1.Text.Trim().ToUpper()
            Dim phone As String = TB_ContactPhone1.Text.Trim().ToUpper()

            Dim dt As DataTable = UpdateContactPhone1(pin_customer_id, phonearea, phone)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If

        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    Protected Sub btnTB_ContactPhone2_Click(sender As Object, e As EventArgs) Handles btnTB_ContactPhone2.Click

        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text)
            Dim phonearea As String = TB_ContactPhoneArea2.Text.Trim().ToUpper()
            Dim phone As String = TB_ContactPhone2.Text.Trim().ToUpper()

            Dim dt As DataTable = UpdateContactPhone2(pin_customer_id, phonearea, phone)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If

        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    Protected Sub btnFaxNo_Click(sender As Object, e As EventArgs) Handles btnFaxNo.Click

        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim faxarea As String = TB_FaxNoArea.Text.Trim().ToUpper()
            Dim fax As String = TB_FaxNo.Text.Trim().ToUpper()

            Dim dt As DataTable = UpdateFax(pin_customer_id, faxarea, fax)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If

        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    Protected Sub btnEmail_Click(sender As Object, e As EventArgs) Handles btnEmail.Click
        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim email As String = TB_Email.Text.Trim().ToUpper()


            Dim dt As DataTable = UpdateEmail(pin_customer_id, email)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If

        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    Protected Sub btnSMSNo_Click(sender As Object, e As EventArgs) Handles btnSMSNo.Click

        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim sms As String = TB_SMSNo.Text.Trim().ToUpper()


            Dim dt As DataTable = UpdateSMSNo(pin_customer_id, sms)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If
        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    'Protected Sub btnDriverLicenceNo_Click(sender As Object, e As EventArgs) Handles btnDriverLicenceNo.Click

    '    Try
    '        Label1.Text = ""
    '        Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text)
    '        Dim driver As String = TB_DriverLicenceNo.Text.Trim().ToUpper()


    '        Dim dt As DataTable = UpdateDriverLicence(pin_customer_id, driver)
    '        If dt.Rows.Count > 0 Then
    '            For Each dr2 As DataRow In dt.Rows
    '                If (dr2("result").ToString() = "0") Then

    '                    Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

    '                Else
    '                    Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
    '                End If
    '            Next
    '        End If
    '    Catch ex As Exception


    '        Session("message") = ex.Message
    '        Response.Clear()
    '        Response.Status = "302 Object Moved"
    '        Response.RedirectLocation = "CX_Exception.aspx"
    '        Response.End()




    '    End Try
    'End Sub

    'Protected Sub btnRegistiredProvince_Click(sender As Object, e As EventArgs) Handles btnRegistiredProvince.Click

    '    Try
    '        Label1.Text = ""
    '        Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text)
    '        Dim regPro As String = TB_RegistiredProvince.Text.Trim().ToUpper()


    '        Dim dt As DataTable = UpdateRegistiredProvince(pin_customer_id, regPro)
    '        If dt.Rows.Count > 0 Then
    '            For Each dr2 As DataRow In dt.Rows
    '                If (dr2("result").ToString() = "0") Then

    '                    Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

    '                Else
    '                    Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
    '                End If
    '            Next
    '        End If

    '    Catch ex As Exception


    '        Session("message") = ex.Message
    '        Response.Clear()
    '        Response.Status = "302 Object Moved"
    '        Response.RedirectLocation = "CX_Exception.aspx"
    '        Response.End()




    '    End Try
    'End Sub

    'Protected Sub btnRegistiredDistrict_Click(sender As Object, e As EventArgs) Handles btnRegistiredDistrict.Click
    '    Try
    '        Label1.Text = ""
    '        Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text)
    '        Dim regdis As String = TB_RegistiredDistrict.Text.Trim().ToUpper()


    '        Dim dt As DataTable = UpdateRegistiredDistrict(pin_customer_id, regdis)
    '        If dt.Rows.Count > 0 Then
    '            For Each dr2 As DataRow In dt.Rows
    '                If (dr2("result").ToString() = "0") Then

    '                    Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

    '                Else
    '                    Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
    '                End If
    '            Next
    '        End If

    '    Catch ex As Exception


    '        Session("message") = ex.Message
    '        Response.Clear()
    '        Response.Status = "302 Object Moved"
    '        Response.RedirectLocation = "CX_Exception.aspx"
    '        Response.End()




    '    End Try
    'End Sub

    Protected Sub btnBirthPlaceProvince_Click(sender As Object, e As EventArgs) Handles btnBirthPlaceProvince.Click

        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim birthPro As String = TB_BirthPlaceProvince.Text.Trim().ToUpper()


            Dim dt As DataTable = UpdateBirthPlaceProvince(pin_customer_id, birthPro)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If

        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    Protected Sub btnBirthPlaceDistrict_Click(sender As Object, e As EventArgs) Handles btnBirthPlaceDistrict.Click

        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim birthDis As String = TB_BirthPlaceDistrict.Text.Trim().ToUpper()


            Dim dt As DataTable = UpdateBirthPlaceDistrict(pin_customer_id, birthDis)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If

        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    Protected Sub btnEmployer_Click(sender As Object, e As EventArgs) Handles btnEmployer.Click

        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim employer As String = TB_Employer.Text.Trim().ToUpper()


            Dim dt As DataTable = UpdateEmployer(pin_customer_id, employer)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If

        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    Protected Sub btnDataShare_Click(sender As Object, e As EventArgs) Handles btnDataShare.Click

        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())

            Dim dataShare As String
            If chckDataShare.Checked = True Then
                dataShare = "Y"
            Else
                dataShare = "N"
            End If


            Dim dt As DataTable = UpdateDataShare(pin_customer_id, dataShare)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If

        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    Protected Sub btnEmployeeOfYourCompany_Click(sender As Object, e As EventArgs) Handles btnEmployeeOfYourCompany.Click
        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())

            Dim EmployeeOfYourCompany As String
            If chckEmployeeOfYourCompany.Checked = True Then
                EmployeeOfYourCompany = "Y"
            Else
                EmployeeOfYourCompany = "N"
            End If


            Dim dt As DataTable = UpdateEmployeeCompany(pin_customer_id, EmployeeOfYourCompany)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If
        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    Protected Sub btnLanguage_Click(sender As Object, e As EventArgs) Handles btnLanguage.Click
        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim lang As Integer = Convert.ToInt32(DDL_Language.SelectedValue)


            Dim dt As DataTable = UpdateLanguage(pin_customer_id, lang)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If

        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    Protected Sub btnNationality_Click(sender As Object, e As EventArgs) Handles btnNationality.Click

        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim national As Integer = Convert.ToInt32(DDL_Nationality.SelectedValue)


            Dim dt As DataTable = UpdateNationality(pin_customer_id, national)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If

        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    Protected Sub btnCustomerType_Click(sender As Object, e As EventArgs) Handles btnCustomerType.Click

        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim type As String = DDL_CustomerType.SelectedValue


            Dim dt As DataTable = UpdateCustomerType(pin_customer_id, type)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If

        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    Protected Sub btnSector_Click(sender As Object, e As EventArgs) Handles btnSector.Click

        Try

            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim sector As String = DDL_Sector.SelectedValue


            Dim dt As DataTable = UpdateSector(pin_customer_id, sector)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If

        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    Protected Sub btnIdentificationNo_Click(sender As Object, e As EventArgs) Handles btnIdentificationNo.Click

        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim id_type As String = DDL_IDTYPE.SelectedValue
            Dim idno As String = TB_IdentificationNo.Text.Trim().ToUpper()


            Dim dt As DataTable = UpdateIdentificationTypeAndNo(pin_customer_id, idno, id_type)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If
        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub


    Private Sub Clear()
        DDL_City.Items.Clear()
        DDL_Note1.Items.Clear()
        TB_CustCode.Text = ""
        TB_CompanyName.Text = ""
        TB_Status.Text = ""
        TB_TaxOffice.Text = ""
        TB_TaxNumber.Text = ""
        TB_Tariff.Text = ""
        TB_PriceGroup.Text = ""
        TB_DealerID.Text = ""
        TB_AuthorizedPersonMSISDN.Text = ""
        TB_AuthorizedPersonName.Text = ""
        TB_AuthorizedPersonEmail.Text = ""
        TB_TCNo.Text = ""
        DDL_IDTYPE.Items.Clear()
        TB_IdentificationNo.Text = ""
        TB_AuthorizedPersonBirthdate.Text = ""
        TB_AuthorizedPersonFatherName.Text = ""
        DDL_Sector.Items.Clear()
        chckDeactiveOverdiscounting.Checked = False
        chckLimitAltiFatura.Checked = False
        TB_NAME.Text = ""
        TB_FNAME.Text = ""
        TB_LNAME.Text = ""
        TB_STREET.Text = ""
        TB_STREETNO.Text = ""
        TB_ADR1.Text = ""
        TB_ADR2.Text = ""
        TB_ADR3.Text = ""
        TB_ZIP.Text = ""
        'TB_CITY.Text = ""
        TB_ContactPhoneArea1.Text = ""
        TB_ContactPhone1.Text = ""
        TB_ContactPhoneArea2.Text = ""
        TB_ContactPhone2.Text = ""
        TB_FaxNoArea.Text = ""
        TB_FaxNo.Text = ""
        TB_Email.Text = ""
        TB_SMSNo.Text = ""
        'TB_DriverLicenceNo.Text = ""
        DDL_Language.Items.Clear()
        DDL_Nationality.Items.Clear()
        'DDL_CustomerType.SelectedValue = ""
        TB_FatherName.Text = ""
        TB_MotherName.Text = ""
        TB_MotherMaidenName.Text = ""
        TB_RegistiredProvince.Text = ""
        TB_RegistiredDistrict.Text = ""
        TB_BirthPlaceProvince.Text = ""
        TB_BirthPlaceDistrict.Text = ""
        chckDataShare.Checked = False
        TB_Employer.Text = ""
        Label1.Text = ""
        chckEmployeeOfYourCompany.Checked = False

    End Sub
    Public Shared Function NullControl(ByVal text As String) As String

        If text = "null" Then
            Return ""
        Else
            Return text
        End If



    End Function
    Protected Sub btnTCNo0_Click(sender As Object, e As EventArgs) Handles btnTCNo0.Click
        If TB_TCNo.Text = "" Then
            Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No Alanı Boş Değer İçermez.');</script>")
        Else
            If CheckBoxMernis.Checked = False Then
                Try
                    Label1.Text = ""
                    Dim d As Double = Double.Parse(TB_TCNo.Text)
                    If TB_TCNo.Text.Length = 11 Then
                        Dim name, surname, gender, fatherName, birthDay, birthMonth, birthYear, cityName, countyName, anneKizlikSoyad, birthPlace As String

                        If (persistent.ChangeSIMpersistence.CheckMernisStatus2(TB_TCNo.Text, name, surname, gender, fatherName, birthDay, birthMonth, birthYear, cityName, countyName, anneKizlikSoyad, birthPlace) = "0") Then


                            lblTcIdControlError.Text = "Geçerli TC No"
                            TB_AuthorizedPersonName.Text = NullControl(name)
                            TB_FNAME.Text = NullControl(name)
                            TB_LNAME.Text = NullControl(surname)
                            'TB_NAME.Text = name
                            TB_FatherName.Text = NullControl(fatherName)
                            TB_MotherMaidenName.Text = NullControl(anneKizlikSoyad)
                            If birthDay.Length = 1 Then
                                birthDay = "0" + birthDay
                            End If
                            If birthMonth.Length = 1 Then
                                birthMonth = "0" + birthMonth
                            End If


                            TB_AuthorizedPersonBirthdate.Text = birthDay + "." + birthMonth + "." + birthYear

                            'TB_BirthPlaceDistrict.Text = birthPlace
                            TB_RegistiredProvince.Text = NullControl(cityName)
                            TB_RegistiredDistrict.Text = NullControl(countyName)
                            'If gender = "Erkek" Then
                            '    DDL_ADR_SEX.SelectedIndex = 1
                            'ElseIf gender = "Kadın" Then
                            '    DDL_ADR_SEX.SelectedIndex = 2
                            'Else
                            '    DDL_ADR_SEX.SelectedIndex = 0
                            'End If
                            lblMernisStatus.Text = 1


                            'If persistent.ChangeSIMpersistence.CheckGreyList(TB_TCNo.Text) = "0" Then
                            '    lblTcIdControlError.Text = lblTcIdControlError.Text + " ve " + "TC Kullanıma Uygundur"
                            '    Button1.Enabled = True

                            'ElseIf persistent.ChangeSIMpersistence.CheckGreyList(TB_TCNo.Text) = "1" Then
                            '    lblTcIdControlError.Text = "TC Blacklistedir"
                            '    Button1.Enabled = False

                            'ElseIf persistent.ChangeSIMpersistence.CheckGreyList(TB_TCNo.Text) = "11" Then
                            '    lblTcIdControlError.Text = "TC Greylistdedir"
                            '    Button1.Enabled = False

                            'Else
                            '    lblTcIdControlError.Text = persistent.ChangeSIMpersistence.CheckGreyList(TB_TCNo.Text).ToString()
                            'End If

                        Else

                            lblTcIdControlError.Text = "TC No geçerli değildir Lütfen tekrar deneyiniz"
                            lblMernisStatus.Text = 2

                            Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No geçerli değildir Lütfen tekrar deneyiniz');</script>")

                        End If

                    Else

                        lblTcIdControlError.Text = "TC No Alanı 11 Karakter Olmalıdır."

                        Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No Alanı 11 Karakter Olmalıdır');</script>")






                    End If
                Catch ex As Exception
                    Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No Alanı Harf İçermez.');</script>")
                End Try
            Else
                Try
                    Label1.Text = ""
                    Dim d As Double = Double.Parse(TB_TCNo.Text)
                    If TB_TCNo.Text.Length = 11 Then
                        Dim name, surname, gender, fatherName, birthDay, birthMonth, birthYear, cityName, countyName, anneKizlikSoyad, birthPlace As String

                        If (persistent.ChangeSIMpersistence.CheckMernisStatusFromGoverment(TB_TCNo.Text, name, surname, gender, fatherName, birthDay, birthMonth, birthYear, cityName, countyName, anneKizlikSoyad, birthPlace) = "0") Then


                            lblTcIdControlError.Text = "Geçerli TC No"
                            TB_AuthorizedPersonName.Text = NullControl(name)
                            TB_FNAME.Text = NullControl(name)
                            TB_LNAME.Text = NullControl(surname)
                            'TB_NAME.Text = name
                            TB_FatherName.Text = NullControl(fatherName)
                            TB_MotherMaidenName.Text = NullControl(anneKizlikSoyad)
                            If birthDay.Length = 1 Then
                                birthDay = "0" + birthDay
                            End If
                            If birthMonth.Length = 1 Then
                                birthMonth = "0" + birthMonth
                            End If


                            TB_AuthorizedPersonBirthdate.Text = birthDay + "." + birthMonth + "." + birthYear

                            'TB_BirthPlaceDistrict.Text = birthPlace
                            TB_RegistiredProvince.Text = NullControl(cityName)
                            TB_RegistiredDistrict.Text = NullControl(countyName)
                            'If gender = "Erkek" Then
                            '    DDL_ADR_SEX.SelectedIndex = 1
                            'ElseIf gender = "Kadın" Then
                            '    DDL_ADR_SEX.SelectedIndex = 2
                            'Else
                            '    DDL_ADR_SEX.SelectedIndex = 0
                            'End If
                            lblMernisStatus.Text = 1


                            'If persistent.ChangeSIMpersistence.CheckGreyList(TB_TCNo.Text) = "0" Then
                            '    lblTcIdControlError.Text = lblTcIdControlError.Text + " ve " + "TC Kullanıma Uygundur"
                            '    'Button1.Enabled = True

                            'ElseIf persistent.ChangeSIMpersistence.CheckGreyList(TB_TCNo.Text) = "1" Then
                            '    lblTcIdControlError.Text = "TC Blacklistedir"
                            '    'Button1.Enabled = False

                            'ElseIf persistent.ChangeSIMpersistence.CheckGreyList(TB_TCNo.Text) = "11" Then
                            '    lblTcIdControlError.Text = "TC Greylistdedir"
                            '    'Button1.Enabled = False

                            'Else
                            '    lblTcIdControlError.Text = persistent.ChangeSIMpersistence.CheckGreyList(TB_TCNo.Text).ToString()
                            'End If
                            lblTcIdControlError.Text = persistent.ChangeSIMpersistence.CheckSingleIwisResult(TB_TCNo.Text)
                            If lblTcIdControlError.Text = "OK" Then
                                'btnTCNo0.Enabled = True
                            Else
                                'btnTCNo0.Enabled = False
                            End If

                        Else

                            ' Response.Write((persistent.ChangeSIMpersistence.CheckMernisStatusFromGoverment(TB_TCNo.Text, name, surname, gender, fatherName, birthDay, birthMonth, birthYear, cityName, countyName, anneKizlikSoyad, birthPlace)))
                            lblTcIdControlError.Text = "TC No geçerli değildir Lütfen tekrar deneyiniz"
                            lblMernisStatus.Text = 2

                            Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No geçerli değildir Lütfen tekrar deneyiniz');</script>")

                        End If

                    Else

                        lblTcIdControlError.Text = "TC No Alanı 11 Karakter Olmalıdır."

                        Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No Alanı 11 Karakter Olmalıdır');</script>")






                    End If
                Catch ex As Exception
                    Me.Page.RegisterStartupScript("javascript", "<script language=""javascript"">alert('TC No Alanı Harf İçermez.');</script>")
                End Try
            End If

         


        End If
    End Sub


    Protected Sub btnLaPrintInvoice_Click(sender As Object, e As EventArgs) Handles btnLaPrintInvoice.Click
        Dim status As Integer
        If chckPrintInvoice.Checked = True Then
            status = 1
        Else
            status = 0


        End If

        Dim dt As DataTable = LAPrintInvoice(Convert.ToInt32(lblCustomerID.Text.Trim()), status)
        If dt.Rows.Count > 0 Then
            If Convert.ToInt32(dt.Rows(0)(0)) = 1 Then
                Label1.Text = "İşlem Başarıyla Gerçekleşti"
            Else
                Label1.Text = "Güncelleme işlemi Başarısız oldu"


            End If


        End If

    End Sub

    Protected Sub btnCustomerName_Click(sender As Object, e As EventArgs) Handles btnCustomerName.Click
        Try
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())

            Dim name As String = TB_NAME.Text.Trim().ToUpper()


            Dim dt As DataTable = UpdateCompanyName(pin_customer_id, name)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If
        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub

    Protected Sub btnMotherMaidenName_Click(sender As Object, e As EventArgs) Handles btnMotherMaidenName.Click
        Try
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())

            Dim mother_maiden_name As String = TB_MotherMaidenName.Text.Trim().ToUpper()


            Dim dt As DataTable = UpdateMotherMaiden(pin_customer_id, mother_maiden_name)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If
        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try

    End Sub

    Protected Sub btnCompanyName_Click(sender As Object, e As EventArgs) Handles btnCompanyName.Click
        Try
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())

            Dim company_name As String = TB_CompanyName.Text.Trim().ToUpper()


            Dim dt As DataTable = UpdateCompanyName(pin_customer_id, company_name)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If
        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()




        End Try
    End Sub



    Private Sub IlceSecim()


        If (DDL_City.SelectedItem.ToString() = "--Seçiniz--") Then

        Else
            DDL_Note1.Items.Clear()
            Dim citycode As Integer = DDL_City.SelectedValue

            ' ErrorMessage.Text = citycode

            Dim dt3 As DataTable = IlceType(citycode)

            If dt3.Rows.Count > 0 Then
                For Each dr3 As DataRow In dt3.Rows
                    DDL_Note1.Items.Add(New ListItem(dr3("DIST_DES").ToString(), dr3("DIST_COD").ToString()))

                Next
            End If
        End If

    End Sub


    Private Sub IlceSecimArama(ByVal citycode As String)


            DDL_Note1.Items.Clear()
        Dim citycode2 As Integer = Convert.ToInt32(citycode)

        'ErrorMessage.Text = citycode

        Dim dt3 As DataTable = IlceType(citycode2)

            If dt3.Rows.Count > 0 Then
                For Each dr3 As DataRow In dt3.Rows
                    DDL_Note1.Items.Add(New ListItem(dr3("DIST_DES").ToString(), dr3("DIST_COD").ToString()))

                Next

        End If

    End Sub

    Private Sub IlSecimSME()



        Dim dt3 As DataTable = IlType()

        If dt3.Rows.Count > 0 Then
            For Each dr3 As DataRow In dt3.Rows
                DDL_City.Items.Add(New ListItem(dr3("ctydes").ToString(), dr3("ctycod").ToString()))

            Next
        End If
    End Sub

    Protected Sub DDL_City_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDL_City.SelectedIndexChanged
        IlceSecim()
    End Sub

    
    Protected Sub bntCityandDist_Click(sender As Object, e As EventArgs) Handles bntCityandDist.Click
        Try
            Label1.Text = ""
            Dim pin_customer_id As Integer = Convert.ToInt32(lblCustomerID.Text.Trim())
            Dim city As String = DDL_City.SelectedItem.Text + "-" + DDL_Note1.SelectedItem.Text

            Dim dt As DataTable = UpdateCustomerCity(pin_customer_id, city)
            If dt.Rows.Count > 0 Then
                For Each dr2 As DataRow In dt.Rows
                    If (dr2("result").ToString() = "0") Then

                        Label1.Text = "Güncelleme İşlemi Başarıyla Gerçekleşti"

                    Else
                        Label1.Text = "Güncelleme İşleminde Hata Oluşmuştur "
                    End If
                Next
            End If

        Catch ex As Exception


            Session("message") = ex.Message
            Response.Clear()
            Response.Status = "302 Object Moved"
            Response.RedirectLocation = "CX_Exception.aspx"
            Response.End()



        End Try
    End Sub
End Class